home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 760 < prev    next >
Internet Message Format  |  1996-08-06  |  2KB

  1. Path: gabi-soft.fr!usenet
  2. From: kanze@gabi-soft.fr (J. Kanze)
  3. Newsgroups: comp.std.c
  4. Subject: Re: Q: char **foo, char *foo[], and char foo[][] ?
  5. Date: 18 Apr 1996 08:59:49 GMT
  6. Organization: GABI Software, Sarl.
  7. Distribution: world
  8. Message-ID: <KANZE.96Apr18105949@gabi.gabi-soft.fr>
  9. References: <4l33ok$oo2@Sherlock.lectra.fr>
  10. NNTP-Posting-Host: gabi.gabi-soft.fr
  11. In-reply-to: phil@rd.lectra.fr's message of 17 Apr 1996 15:46:28 GMT
  12.  
  13. In article <4l33ok$oo2@Sherlock.lectra.fr> phil@rd.lectra.fr (Philippe
  14. Maurisset) writes:
  15.  
  16. |> Considering the 3 following declarations:
  17.  
  18. |> 1 - char **foo;
  19. |> 2 - char *foo[];
  20. |> 3 - char foo[][];
  21.  
  22. |> I know that there is a (big !) difference in memory reservation, but I do not know
  23. |> if foo IS or IS NOT of the same type in these three cases.
  24.  
  25. They are definitly not the same type, however...
  26.  
  27. |> To summarize my question :
  28. |> Is the first one securely usable for casting a variable of the third kind, when
  29. |> calling a function where it is defined as the second kind ?
  30.  
  31. |> Follwing is a description (the 2 functions are in differents sources files) :
  32.  
  33. |> myexample()
  34. |> {
  35. |>     char foo[MAX_X][MAX_Y];
  36. |>     ...
  37. |>     myfunc( (char **)foo );
  38. |> }
  39.  
  40. |> void myfunc( char *foo[MAX_X] )
  41.                 ^^^^^^^^^^^^^^^^
  42.  
  43. Because it appears as a function parameter, this is actually a
  44. declaration of a char**, and not a char*[].
  45.  
  46. So in fact, you have no type incompatibility to deal with.
  47. -- 
  48. James Kanze           (+33) 88 14 49 00          email: kanze@gabi-soft.fr
  49. GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
  50. Conseils en informatique industrielle --
  51.                             -- Beratung in industrieller Datenverarbeitung
  52.